<?php
namespace Modules\AuthAdmin\Http\Controllers\v1;
use Illuminate\Http\Request;
use Modules\AuthAdmin\Models\AuthConfig as AuthConfigModel;
use Modules\AuthAdmin\Models\AuthImage as AuthImageModel;
use Modules\AuthAdmin\Services\CommonService;
class ConfigController extends CommonController
{
	/**
	 * @name  获取配置信息
	 * @method  GET	
	 * @return  JSON
	 */
    public function config_info(Request $request)
    {	
		return (new AuthConfigModel())->config_info();
		
    }
	/**
	 * @name  系统配置
	 * @method  GET	
	 * @return  JSON
	 */
    public function index(Request $request)
    {	
		return (new AuthConfigModel())->edit_data();
		
    }
	/**
	 * @name  提交
	 * @method  PUT	
	 * @param  id int 系统配置ID	
	 * @param  name string 站点名称	
	 * @param  image_status int 图片储存:1=本地,2=七牛云	
	 * @param  image_id int 站点logo	
	 * @param  about_us string 关于我们	
	 * @return  JSON
	 */ 
    public function update(Request $request)
    {
		$data = $request->all();
		$data['about_us'] = (new CommonService())->remve_pic_url($data['about_us']);
		$data = (new AuthImageModel())->edit_image('auth_configs',$data['id'],$data);
		return (new AuthConfigModel())->common_update($data['id'],[
			'name'=>$data['name'],
			'image_status'=>$data['image_status'],
			'about_us'=>$data['about_us'],
			'image_id'=>$data['image_id'], 
			'gzh_id'=>$data['gzh_id'], 
			'xcx_id'=>$data['xcx_id']
		],'配置成功！','配置失败！'); 
    }
}
